﻿using System;

class ExtractBitAtSpecificPosition
{
    static void Main()
    {
        int number;
        int bitPositionB;

        Console.WriteLine("Type a number:");
        bool isNumberValid = int.TryParse(Console.ReadLine(), out number);
        Console.WriteLine("Type position p:");
        bool isBitPositionBValid = int.TryParse(Console.ReadLine(), out bitPositionB);

        if (isNumberValid && isBitPositionBValid)
        {
            int bitAtPositionP = (number >> bitPositionB) % 2;
            Console.WriteLine("The bit at posiotion {0} is {1}", bitPositionB, bitAtPositionP);
        }
        else
        {
            Console.WriteLine("Your input isn`t OK!!!");
        }
    }
}
